//可视化反馈得分  

var Assignment
var orderClassname=[]
window.onload = function() { 
	var $_REQUEST = new Object, aParams = unescape(document.location.search.substr(1)).split("&");
	Assignment=JSON.parse(aParams)	
	getRftItemScoreInfo(Assignment)   //该函数可以实现先加载页面资源再执行函数
	};
	
function getRftItemScoreInfo(assignment){
	$.ajax({
		   url: "/pad/experiment/getRftScoreFigInfo",
		   type: 'POST',
		   data:Assignment,
		   async: false,
		   dataType: "json", //返回数据格式为json
		   success: function(data) {//请求成功完成后要执行的方法
			   //console.log(data)
			   var xlabel=data.className  //横轴类别
			   var rftType=data.rftType   //两种反馈类别
			   var tempData=data.serisData
			   var resData=[]
			   var figName=data.courseInfo.courseName
			   $("#figName").html(figName+"——"+Assignment.assignmentName)
			   var minScore=data.minScore
			   var maxScore=data.maxScore
			   for(var i=0;i<rftType.length;i++){
				   for (var key in tempData) {  
					   if(rftType[i]==key){
						   var newBarr=[] //封装一个类型盒子数据的 大数组
						   for(var j=0;j<tempData[key].length;j++){
							   newBarr.push(tempData[key][j].map(Number))
						   }
						   bdata=echarts.dataTool.prepareBoxplotData(newBarr)
						  // bdata.outliers=[]  看看异常值会怎么样处理
						   resData.push({
	                           name: rftType[i],
	                           type: 'boxplot',
	                           data:bdata.boxData,
	                           tooltip:{formatter:formatter}
	                       });
					   }
				   }
			   }
			   var myChart = echarts.init(document.getElementById('main'));
			   option = {
					    title: {
					        text: '反馈得分可视化分析',
					        left: 'center',
					    },
					    legend: {
					        top: '10%',
					        data:rftType
					    },
					    tooltip: {
					        trigger: 'item',
					        axisPointer: {
					            type: 'shadow'
					        }
					    },
					    grid: {
					        left: '10%',
					        top: '20%',
					        right: '10%',
					        bottom: '15%'
					    },
					    xAxis: {
					        type: 'category',
					        name: '反馈类别',
					        data: xlabel,
					        boundaryGap: true,
					        nameGap: 30,
					        splitArea: {
					            show: true
					        },
					        axisLabel: {
					            formatter: '{value}'
					        },
					        splitLine: {
					            show: false
					        }
					    },
					    yAxis: {
					        type: 'value',
					        name: '反馈得分',
					        min: 0, 
					        max: 6,
					        splitArea: {
					            show: false
					        }
					    },
					    dataZoom: [
					        {
					            type: 'inside',
					            start: 0,
					            end: 20
					        },
					        {
					            show: true,
					            height: 20,
					            type: 'slider',
					            top: '90%',
					            xAxisIndex: [0],
					            start: 0,
					            end: 20
					        }
					    ],
					    series:resData,
					};
			      myChart.setOption(option);	   
		   }
	         });
	$("#jiazai").hide()
}

function formatter(param) {
	//console.log(param)
	  return [
	        '反馈类别: ' + param.name,
	        '最大值: ' + param.data[5],
	        '中位数: '+ param.data[3],
	        '最小值: ' + param.data[1]
	    ].join('<br/>');
}


				